﻿<!DOCTYPE html>
<html>
<head>
    <title></title>
    <link rel="stylesheet" href="../Font/iconfont.css?1">
    <link rel="stylesheet" href="../Layui/css/layui.css" media="all">
    <link type="text/css" href="../Skin/Plane/css/Manager.css?20181116" rel="stylesheet" />
    <script src="../Layui/layui.js"></script>
    <script type="text/javascript" src="../Htc/jquery-1.11.2.min.js"></script>
    <script type="text/javascript" src="../Htc/ManagerLay.js?20181120"></script>
</head>
<body>
    <script type="text/javascript" language="javascript">
        //删除参数
        var PageType = "@ViewBag.Pg.Type";	//原类型
        var PageDelPrompt = "@ViewBag.Pg.Sop.DEL_prompt";	//删除提示
        var DelType = "@ViewBag.Pg.Type";		//参数
        //跳转页参数
        var CurPage = 1;
        var OrderField = "@ViewBag.Pg.OrderField";
        var OrderType = @ViewBag.Pg.OrderType;
        var KeyFieldName = "@ViewBag.Pg.KeyFieldName";
        //增加修改参数
        var FileUrl = "@Html.Raw(ViewBag.Pg.FileUrl)";		//文件地址
        var PopEditWidth = "@ViewBag.Pg.PopEditWidth";	//宽度
        var PopEditHeight = "@ViewBag.Pg.PopEditHeight";	//高度
        var NewWindow = @ViewBag.Pg.NewWindow.ToString().ToLower();
        var AddText = "@ViewBag.Pg.AddText";
        var EditText = "@ViewBag.Pg.EditText";
        var ImportText = "@ViewBag.Pg.ImportText";
        var PromptInfo = "@ViewBag.Pg.PromptInfo";
        var UrlAddPara = "@Html.Raw(ViewBag.Pg.UrlAddPara)";
        var UrlEditPara = "@Html.Raw(ViewBag.Pg.UrlEditPara)";
        var LocateText = "@ViewBag.Pg.LocateText";
        var DataPageUrl = "@Html.Raw(ViewBag.DataPageUrl)";
        var DelUrl = "@Html.Raw(ViewBag.DelUrl)";
        var ImportUrl = "@Html.Raw(ViewBag.ImportUrl)";
        var ExportUrl = "@Html.Raw(ViewBag.ExportUrl)";
        var DataPageSubUrl = "@Html.Raw(ViewBag.DataPageSubUrl)";
        var CustomPara = "";
        var LocatePara = "@ViewBag.Pg.FirstCondition";
        var PageSize = @ViewBag.PageSize;
        var TableHeight = "full-180";//表格高度
        var IsEdit = @ViewBag.Pg.Sop.EDIT.ToString().ToLower();
        $(document).ready(function () {

            $("#locateOk").click(function () { locate_OK(); return false; });
            $("#locateOk2").click(function () { locate_OK(); return false; });
            $(".LocateTable input[type=text]").addClass("layui-input");
            $(".LocateTable input[type=password]").addClass("layui-input");
            $(".LocateTable2 input[type=text]").addClass("layui-input");
            $(".LocateTable2 input[type=password]").addClass("layui-input");

            layui.use(['element', 'table', 'layer', 'laypage', 'form', 'laydate'], function () {
                $(".LocateDate").each(function () {
                    layui.laydate.render({
                        elem: '#' + $(this).attr("id") //指定元素
                    });
                })
                $(".LocateDateTime").each(function () {
                    layui.laydate.render({
                        type:"datetime",
                        elem: '#' + $(this).attr("id") //指定元素
                    });
                })

                TableHeight = "full-" + ($("#DataPageHTML").offset().top + 80);

                if ($("#TabPage li").length > 0) {
                    $("#TabPage li").eq(0).click();
                   
                }
                else
                    GoPage(1);
            });
        });

        function locate_OK()//查询：确定
        {
            HideModal('popLocate');
            var para = "";
            //后台生成取值脚本
            @Html.Raw(ViewBag.Pg.LocateScript)

            if (document.getElementById("LocateCHK").checked)
                LocatePara += para;
            else
                LocatePara = para;

            GoPage(CurPage);
        }

        @Html.Raw(ViewBag.Pg.Script)
    </script>
    @{
        var isLocate = false;
        var isLocate2 = false;
        var isButton = false;
        for (int i = 0; i < ViewBag.Pg.LocateTable.Count; i++)
        {
            var position = ViewBag.Pg.ColumnInfo[ViewBag.Pg.LocateTable[i][0]].ConditionPosition;
            if (position == 0)
            {
                isLocate = true;
                continue;
            }
            if (position == 1)
            {
                isLocate2 = true;
                continue;
            }
        }
        isButton = isLocate2 && (
                    ViewBag.Pg.Button.Count > 0
                    || ViewBag.Pg.Sop.ADD || ViewBag.Pg.Sop.EDIT || (ViewBag.Pg.FileUrl != "" && ViewBag.Pg.Sop.BROWSE && !ViewBag.Pg.Sop.EDIT)
                    || ViewBag.Pg.Sop.DEL || ViewBag.Pg.Sop.IMPORT || ViewBag.Pg.Sop.EXPORT
                  );
    }

    <div class="layui-fluid" style="margin-top:15px;">
        @if (isLocate2 || isLocate || isButton)
        {
            <div class="layui-card">
                <div class="layui-card-body">
                    @if (isLocate2)
                    {
                        <!--快速查询栏-->
                        <div id="popLocate2">
                            <form id="form2" class="layui-form">
                                <div class="LocateTable2">
                                    @for (int i = 0; i < ViewBag.Pg.LocateTable.Count; i++)
                                    {
                                        var position = ViewBag.Pg.ColumnInfo[ViewBag.Pg.LocateTable[i][0]].ConditionPosition;
                                        if (position == 1)
                                        {

                                            <div class="tdLabel"> @Html.Raw(ViewBag.Pg.LocateTable[i][1]) </div>
                                            <div class="layui-input-inline tdInput"> @Html.Raw(ViewBag.Pg.LocateTable[i][2]) </div>
                                        }
                                    }
                                    <button id="locateOk2" class="layui-btn"><i class="layui-icon layui-icon-search"></i></button>
                                    @if (isLocate)
                                    {
                                        <button id="btn_locate" class="layui-btn" onclick="locate(); return false;"><i class="layui-icon layui-icon-more"></i></button>
                                    }
                                </div>
                            </form>
                        </div>
                    }
                    @if (isButton)
                    {
                        <hr />
                    }
                    <!--按钮栏-->
                    <div class="tools">
                        <ul class="toolbar">
                            @foreach (var button in ViewBag.Pg.Button)
                            {
                                @Html.Raw(button)
                            }
                            @if (ViewBag.Pg.Sop.ADD)
                            {
                                @Html.Raw(ViewBag.Pg.Sop.ADD_htm)
                                if (ViewBag.Pg.Sop.ADD_htm == "")
                                {
                                    <li id="btn_add" onclick="add()" class="layui-btn layui-btn-normal"><i class="layui-icon layui-icon-add-1"></i>增加</li>
                                }
                            }
                            @if (ViewBag.Pg.Sop.EDIT)
                            {
                                @Html.Raw(ViewBag.Pg.Sop.EDIT_htm)
                                if (ViewBag.Pg.Sop.EDIT_htm == "")
                                {
                                    <li id="btn_mod" onclick="edit()" class="layui-btn layui-btn-normal"><i class="layui-icon layui-icon-edit"></i>修改</li>
                                }
                            }
                            @if (ViewBag.Pg.FileUrl != "" && ViewBag.Pg.Sop.BROWSE && !ViewBag.Pg.Sop.EDIT)
                            {
                                @Html.Raw(ViewBag.Pg.Sop.BROWSE_htm)
                                if (ViewBag.Pg.Sop.BROWSE_htm == "")
                                {
                                    <li id="btn_browse" onclick="edit()" class="layui-btn layui-btn-normal"><i class="iconfont icon-chakan-copy"></i>查看</li>
                                }
                            }
                            @if (ViewBag.Pg.Sop.DEL)
                            {
                                @Html.Raw(ViewBag.Pg.Sop.DEL_htm)
                                if (ViewBag.Pg.Sop.DEL_htm == "")
                                {
                                    <li id="btn_del" onclick="DelType=PageType;del(PageDelPrompt);" class="layui-btn layui-btn-normal"><i class="layui-icon layui-icon-delete"></i>删除</li>
                                }
                            }
                            @if (ViewBag.Pg.Sop.IMPORT)
                            {
                                @Html.Raw(ViewBag.Pg.Sop.IMPORT_htm)
                                if (ViewBag.Pg.Sop.IMPORT_htm == "")
                                {
                                    <li id="btn_import" onclick="importXls()" class="layui-btn layui-btn-normal"><i class="iconfont icon-daoru"></i>导入</li>
                                }
                            }
                            @if (ViewBag.Pg.Sop.LOCATE)
                            {
                                @Html.Raw(ViewBag.Pg.Sop.LOCATE_htm)
                                if (ViewBag.Pg.Sop.LOCATE_htm == "" && isLocate && !isLocate2)
                                {
                                    <li id="btn_locate" onclick="locate()" class="layui-btn layui-btn-normal"><i class="layui-icon layui-icon-search"></i>查询</li>
                                }
                            }
                            @if (ViewBag.Pg.Sop.EXPORT)
                            {
                                @Html.Raw(ViewBag.Pg.Sop.EXPORT_htm)
                                if (ViewBag.Pg.Sop.EXPORT_htm == "")
                                {
                                    <li id="btn_export" onclick="exportXls()" class="layui-btn layui-btn-normal"><i class="iconfont icon-daochu"></i>导出</li>
                                }
                            }
                        </ul>
                    </div>
                </div>
            </div>
        }
        <div class="layui-card">
            <div class="layui-card-body">
                @if (ViewBag.Pg.Tab.Count > 0)
                {
                    <div id="TabPage" class="layui-tab layui-tab-brief" lay-filter="TabPage">
                        <ul class="layui-tab-title">
                            @{
                                var i = 0;
                                foreach (var dr in ViewBag.Pg.Tab)
                                {
                                    if (i++ == 0)
                                    {
                                        <li onclick="@Html.Raw(dr.Value)" class="layui-this">@Html.Raw(dr.Key)</li>
                                    }
                                    else
                                    {
                                        <li onclick="@Html.Raw(dr.Value)">@Html.Raw(dr.Key)</li>
                                    }
                                }

                            }
                        </ul>
                    </div>
                }
                <!--数据表格栏-->
                @if (ViewBag.DataPageSubUrl == "")
                {
                    <table class="layui-hide" id="dgrid" lay-filter="dgrid"></table>
                }
                <div id="DataPageHTML"></div>
            </div>
        </div>
    </div>


    <div id="popLocate" style="display:none;">
        <form id="form1" class="layui-form">
            <div class="LocateTable">
                <table>
                    @{
                        var a = 0;

                        for (int i = 0; i < ViewBag.Pg.LocateTable.Count; i++)
                        {
                            var position = ViewBag.Pg.ColumnInfo[ViewBag.Pg.LocateTable[i][0]].ConditionPosition;
                            if (position == 0)
                            {
                                if (a % ViewBag.Pg.ConditionColumn == 0)
                                {
                                    @Html.Raw("<tr>")
                                }
                                <td class="tdLabel">@Html.Raw(ViewBag.Pg.LocateTable[i][1])</td>
                                <td class="tdInput">@Html.Raw(ViewBag.Pg.LocateTable[i][2])</td>
                                if (a % ViewBag.Pg.ConditionColumn == ViewBag.Pg.ConditionColumn - 1)
                                {
                                    @Html.Raw("</tr>")
                                }

                                a++;
                            }
                        }

                        int k = a % ViewBag.Pg.ConditionColumn;
                        int m = (ViewBag.Pg.ConditionColumn - k) * 2;
                        if (k > 0)
                        {
                            @Html.Raw("<td colspan=" + m + "></td></tr>")
                        }
                    }
                </table>
            </div>
        </form>
        <input type="checkbox" id="LocateCHK" /><label for="LocateCHK">在结果中查询</label>

        <div class="LocateButton">
            <button id="locateOk" class="layui-btn layui-btn-normal">确定</button>
            <button class="layui-btn layui-btn-primary" onclick="HideModal('popLocate');return false;">关闭</button>
        </div>
    </div>


</body>
</html>
